/*
 * SalesTester.java
 *
 * Created on March 29, 2007, 8:31 PM
 *
 */

package edu.byu.isys413.mystuff.sales;

import edu.byu.isys413.mystuff.DataException;
import edu.byu.isys413.mystuff.*;

/**
 *
 * @author Gabe
 */
public class SalesTester {
    
    /** Creates a new instance of SalesTester */
    public SalesTester() {
    }
    public static void main(String[] args)throws DataException{
        //setting up instance of rsfactory
//        RSFactory factory = RSFactory.getInstance();
        
        //calling the factory of type sale so we can get the saleDAO
//        revaDAO revDAO = factory.getDAO("sale");
        //instantiate sales bo with nothing in it
        SalesBO saleBO = null;
//        try{
//            //this actually makes sales bo into a revbo because that is what is returning
//            saleBO = (SalesBO)revDAO.create();
//        }catch(Exception e){
//            e.printStackTrace();
//        }
//        //we are setting these items not in the sales bo but in the revsource bo
//        saleBO.setDescription("this is the decrisption");
//        saleBO.setPrice(20.00);
//        saleBO.setType("sale");
//        saleBO.setQuantity(1);
//        //set up instance of forsale dao
        System.out.println("***************Physical Product Sale*****************");
        String productID = "p111111111876a786adadeeffbc124955";
        if(productID.charAt(0)=='p'){
            try{
                
                //remember that the salebo is really a revbo in the form of a sale
                ForSaleBO forSale = forSaleDAO.getInstance().read(productID);
                
//            saleBO.setProduct(forSale);
                System.out.println("SALE: The ID is: " + forSale.getId());
                System.out.println("SALE: The description is: " + forSale.getProductID());
                System.out.println("SALE: The Price is: " + forSale.getPrice());
                System.out.println("SALE: the type is: " + forSale.getStoreID());
                System.out.println("SALE: the Product's SKU is: " + forSale.getSku());
                
            }catch(Exception e){
                e.printStackTrace();
            }
            
        }//end forSale if
        System.out.println("***************Testing Conceptual Sale*****************");
        if(productID.charAt(0)=='c'){
            
            try{
                ConceptualBO conceptualBO = (ConceptualBO)ConceptualDAO.getInstance().read(productID);
                
                System.out.println("Conceputal Sale: The ProductID is: " + conceptualBO.getProductID());
                System.out.println("Conceputal Sale: The Price is: " + conceptualBO.getPrice());
                System.out.println("Conceputal Sale: the Average Cost is: " + conceptualBO.getAverageCost());
                System.out.println("Conceputal Sale: the Product's CategoryID is: " + conceptualBO.getCategoryID());
                System.out.println("Conceputal Sale: the Product's ProductName is: " + conceptualBO.getProductName());
                //saleBO.setProduct(conceptualBO);
            }catch(Exception e){
                e.printStackTrace();
            }
        }//end conceptual if
        
        
        
        
//    try{
//            //revDAO.save(saleBO);
//        }catch(Exception e){
//            e.printStackTrace();
//        }
//
//        //read from the database
//        try{
//            saleBO= (SalesBO)revDAO.read("p111111111876a786adadeeffbc124955");
//
//            System.out.println("SALE: The ID is: " + saleBO.getRevSrcID());
//            System.out.println("SALE: The description is: " + saleBO.getDescription());
//            System.out.println("SALE: The Price is: " + saleBO.getPrice());
//            System.out.println("SALE: the type is: " + saleBO.getType());
//            System.out.println("SALE: the Product's SKU is: " + saleBO.getProduct().getSKU());
//            System.out.println("");
//
////        System.out.println("the Quantity for the sale is: " + saleBO.getQuantity());
//        }catch(Exception e){
//            e.printStackTrace();
//        }
//
//
//
//
    }
    
}
